
function TasksDTO() {
	this.tasks = new Array();
}

TasksDTO.prototype.addTask = function(task) {
	this.tasks[this.tasks.length] = task;
}

TasksDTO.prototype.getTasks = function() {
	return this.tasks;
}

TasksDTO.prototype.getTasksInInterval = function(cellStartDate, cellFinishDate) {
	var tasks = new Array();
	
	for(var i=0; i<this.getTasks().length; i++) {
		var task = this.getTasks()[i];
		var taskStartDate = task.getStartDate();
		var taskFinishDate = task.getFinishDate();
		
		var found = false;
		
		// task is totally inside the cell
		if(taskStartDate>=cellStartDate && taskFinishDate<=cellFinishDate) {
			found = true;
		}

		// task totally covers cell
		if(taskStartDate<=cellStartDate && taskFinishDate>=cellFinishDate) {
			found = true;
		}

		// tasks ends inside cell
		if(taskFinishDate>=cellStartDate && taskFinishDate<=cellFinishDate) {
			found = true;
		}

		// tasks begins inside cell
		if(taskStartDate>=cellStartDate && taskStartDate<=cellFinishDate) {
			found = true;
		}

		if(found) {
			tasks[tasks.length] = task;
		}

	}
	
	return tasks;
}